home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Communication / NewsBase / Source / IPercentageView.m < prev    next >
Text File  |  1993-01-12  |  1KB  |  59 lines

  1.  
  2. /* Generated by Interface Builder */
  3.  
  4. #import "IPercentageView.h"
  5. #import <dpsclient/wraps.h>
  6. #import <appkit/graphics.h>
  7.  
  8. @implementation IPercentageView
  9.  
  10. - initFrame:(const NXRect *)frameRect
  11. {
  12.     [super initFrame:frameRect];
  13.     iMin = 0.0;
  14.     iMax = 1.0;
  15.     return self;
  16. }
  17.  
  18. - setMin:(float)amin max:(float)amax
  19. {
  20.     iMin = amin;
  21.     iMax = amax;
  22.     if (iMin > iMax) {
  23.     fprintf(stderr,"IPercentageView: min is larger than max\n");
  24.     return nil;
  25.     }
  26.     return self;
  27. }
  28.  
  29. - displayValue:(float)aval
  30. {
  31.     iVal = aval;
  32.     return ([self display]);
  33. }
  34.  
  35. - resetValue
  36. {
  37.     [self setMin:0.0 max:0.0];
  38.     return ([self display]);
  39. }
  40.  
  41. - drawSelf:(const NXRect *)rects :(int)rectCount
  42. {
  43.     NXRect    drawRect;
  44.     
  45.     drawRect = *rects;
  46.     NXDrawGrayBezel(&bounds, NULL);
  47.     NXInsetRect(&drawRect, 2.0, 2.0);
  48.     if ((iMax-iMin) != 0) {
  49.     drawRect.size.width = drawRect.size.width * (iVal - iMin) / (iMax - iMin);
  50.     PSsetgray(NX_DKGRAY);
  51.     PSrectfill(drawRect.origin.x, drawRect.origin.y,
  52.                  drawRect.size.width, drawRect.size.height);
  53.     }
  54.  
  55.     return ([super drawSelf:rects :rectCount]);
  56. }
  57.  
  58. @end
  59.